package net.huashitong.Indicators.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.Indicators.entity.UserInfo;
import org.springframework.stereotype.Repository;

@Repository
public class UserInfoDao extends StringDao<UserInfo> {

    public UserInfo queryByUser(String userId){
        GenericQuery query = createQuery("obj");
        if(StringUtils.isNotBlank(userId)){
            query.append(" and obj.userId=:userId").setParam("userId", userId);
        }
        return query.firstResult();
    }

    public UserInfo queryByTel(String tel){
        GenericQuery query = createQuery("obj");
        if(StringUtils.isNotBlank(tel)){
            query.append(" and obj.tel=:tel").setParam("tel", tel);
        }
        return query.firstResult();
    }
}
